#pragma once

namespace Base { namespace CmdFwk {

    class Command;
    class InteractiveCmd;
    class CmdDef;

    class CmdMgr
    {
    private:
        CmdMgr();
        ~CmdMgr();
        
    public:
        static CmdMgr* get();
        
        InteractiveCmd* activeCmd() const;
        void deactivateCmd();
        
        // Launch a command.
        void doCmd(const void* cmdId);

        // Get and search the command definition.
        void addCmdDef(CmdDef*);
        const CmdDef* cmdDef(const void* cmdId) const;

        // Get the command definitions that belongs to an environment.
        const std::vector<const CmdDef*> commandsIn(const void* envId);

    private:
        void doCmd(Command*);
        void activateCmd(InteractiveCmd*);
        
    private:
        typedef std::map<const void*, CmdDef*> CmdDefs;

        InteractiveCmd* m_activeCmd;
        CmdDefs         m_cmdDefs;
    };

}}